Skip to main content

Pataa Set delivery location SDK Implementation Guide

image

image

image

Step 1. Download Pataa_autofill_sdk.arr file from the git repository

https://github.com/pataa-com/Address-Autofill-Android

Step 2. Put pataa_autofill_sdk.aar in your project lib folder

Step 3. Add below line in app level build.gradle


implementation fileTree(dir: "libs", include: ["*.aar"])

Step 4. Add Metadata in manifest

<meta-data
android:name="pataa.autofill.sdk.ClientKey"
android:value="@string/PATAA_API_KEY" />

<meta-data
android:name="pataa.autofill.sdk.EnableLogger"
android:value="true" />

<meta-data
android:name="pataa.autofill.sdk.EnableDevelopment"
android:value="false" />

Step 5. Add view on xml(Don't change the id)

    <com.pataa.sdk.PataaAddressSdk
android:id="@+id/btnAddressView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:addressLineBackColor="@color/color_D8DEEB"
app:addressLinePreText="Ship To"
app:addressLineTextColor="@color/black"
app:backgroundColor="@color/black"
app:editTextColor = "@color/white"
app:cardCornerRadius="10dp"
app:keepLastSessionData="true"
app:sessionKey="abc"
app:showAddressLine="true"
app:textColor="@color/white" />

addressLineBackColor : Set color for address line back color default color will be while

addressLinePreText : Set prefix text for address line by default it will be "ship to"

addressLineTextColor : Set text color for address line default will be black

backgroundColor : Set background color of button default will be black

editTextColor : Set Button text color default will be white

cardCornerRadius : Set button corner radius

keepLastSessionData : Set True for manage last session data

sessionKey : For save last address data put your unique key here

showAddressLine : For hide/show bottom address line

textColor : Set Buton text color default will be white

Step 6. Set properties and listener(Only for JAVA),

((PataaAddressSdk)findViewById(R.id.btnAddressView)).setCurrentActivity(this)
.setCountryCode("##PUT COUNTRY CODE WITH +##(IN INDIA +19)").setMobileNo("## PUT LOGIN USER MOBILE NO ##")
//to get the result of create pataa
.setAddressCallBack(new OnAddressGet() {//to get the click events
@Override
public void onNetworkIsNotAvailable() {
Toast.makeText(MainActivity.this, "onNetworkIsNotAvailable", Toast.LENGTH_SHORT).show();
}

@Override
public void onPataaFound(User user, Pataa response) {
Log.e("TAG", "onManualAddressFound: " + response);
}

@Override
public void onManualAddressFoound(JSONObject jsonObject) {
Log.e("TAG", "onManualAddressFound: " + jsonObject);

}

@Override
public void onError(int statusCode, String message) {
Toast.makeText(MainActivity.this, statusCode + " : " + message, Toast.LENGTH_SHORT).show();
}
});

Step 7. Set properties and listener(Only for Kotlin),

   (findViewById<View>(R.id.btnAddressView) as PataaAddressSdk).setCurrentActivity(this)
.setCountryCode("##PUT COUNTRY CODE WITH +##(IN INDIA +19)")
.setMobileNo("## PUT LOGIN USER MOBILE NO ##") //to get the result of create pataa
.setAddressCallBack(object : OnAddressGet {
//to get the click events
override fun onNetworkIsNotAvailable() {
Toast.makeText(this@MainActivity, "onNetworkIsNotAvailable", Toast.LENGTH_SHORT)
.show()
}
override fun onPataaFound(user: User, response: Pataa) {
Log.e("TAG", "onManualAddressFound: $response")
}

override fun onManualAddressFoound(jsonObject: JSONObject) {
Log.e("TAG", "onManualAddressFound: $jsonObject")
}

override fun onError(statusCode: Int, message: String) {
Toast.makeText(this@MainActivity, "$statusCode : $message", Toast.LENGTH_SHORT)
.show()
}
})

In Pataa found response you will found Pataa Object you can use it as you required

You will found following details in Pataa object:

pataa_code, address1, address2, address3, address4, zipcode, city_name, state_code, state_name, country_code, country_name, qr_code, lati, logi,

Step 9. Add PATAA api key on string.xml.

  <resources>
.....
<string name="PATAA_API_KEY"></string>
<resources>

In case of errors

  E/PATAA_SDK_LOGS: {"msg":"Invalid App key","status":600}
E/PATAA_SDK_LOGS: Invalid App key

Solution : Enable logs from manifest metadata and copy the SHA1 key. Put it on pataa developer console, and then try again you will got the results

  E/PATAA_SDK_LOGS: {"msg":"Your key is deavtivated please generate new","status":200}
E/PATAA_SDK_LOGS: Invalid App key

Solution : Enable the key for use on Pataa developer console or Create new key.

 E/PATAA_SDK_LOGS: {"msg":"Pataa Code not found","status":204}
E/PATAA_SDK_LOGS: Pataa Code not found

Solution : Try to search with valid pataa code like - KUMAR100, SINGH221, Because your searched pataa code is not created on pataa platform yet.

   E/PATAA_SDK_LOGS: {"msg":"Pataa Search Limit Over","status":400}
E/PATAA_SDK_LOGS: Pataa Search Limit Over
E/PATAA_SDK_LOGS: {"msg":"Invalid API key or App key,you are not authorized.Please provide a valid key","status":400}
E/PATAA_SDK_LOGS: Invalid API key or App key,you are not authorized.Please provide a valid key